#include "Camera.h"
#include "SceneNode.h"

Camera::Camera() {
	fov = 33.3f;
	near = 0.1f;
	far = 300.0f;
}

Camera::~Camera() {
}

void Camera::Set(Vector3D pos, Vector3D _lookAt, Vector3D _upVector) {
	TranslateObj(pos);
	lookAt = _lookAt;
	upVector = _upVector;
}

void Camera::SetLookAt(Vector3D _lookAt) {
	lookAt = _lookAt;
}

void Camera::SetUpVector(Vector3D _upVector) {
	upVector = _upVector;
}

void Camera::SetFOV(f32 _fov) {
	fov = _fov;
}

void Camera::SetFar(f32 _far) {
	far = _far;
}
void Camera::SetNear(f32 _near) {
	near = _near;
}

f32 Camera::GetFOV() {
	return fov;
}

f32 Camera::GetFar() {
	return far;
}

f32 Camera::GetNear() {
	return near;
}

Mtx* Camera::GetViewMatrix() {
	return &viewMtx;
}

void Camera::ApplyCamera() {
	//Compute real cam position in world
	Vector3D computedCamPosition = parentNode->GetTranslation() + transObj;
	
	//Create guVectors for GX
	guVector camPos = computedCamPosition.toGuVector();
    guVector camUpVec = upVector.toGuVector();
	guVector camLookAt = lookAt.toGuVector();
    
	//Apply parameters to view matrix
	guLookAt(viewMtx, &camPos, &camUpVec, &camLookAt);
}

